/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bsd5ex.group1.kaokang.dao;

import com.bsd5ex.group1.kaokang.config.TableNameConstants;
import com.bsd5ex.group1.kaokang.model.KitchenWare;
import com.bsd5ex.group1.kaokang.model.KitchenWareType;
import java.util.HashMap;
import java.util.List;

/**
 *
 * @author VAIO
 */
public class KitchenWareTypeDAO extends AbstractDAO<KitchenWareType> {

    private static boolean initialized = false;
    
    private static HashMap<String, KitchenWareType> cache = new HashMap<String, KitchenWareType>();
    
    public static void refreshCache() {
        List<KitchenWareType> allTypes = new KitchenWareTypeDAO().listAll();
        for (KitchenWareType kitchenWareType : allTypes) {
            cache.put(kitchenWareType.getKitchenWareTypeName(), kitchenWareType);
        }
        initialized = true;
    }
    
    public static KitchenWareType getKitchenWareType(String typeName) {
        if( !initialized ) {
            refreshCache();
        }
        return cache.get(typeName);
    }
    
}
